/*
    4. Write a program in C to read the file and store the lines into an array. Go to the editor
    Test Data :
    Input the file name to be opened : test.txt
    Expected Output :

    The content of the file test.txt  are :                                                                      
    test line 1                                                                                                  
    test line 2                                                                                                  
    test line 3                                                                                                  
    test line 4
*/

#include <stdio.h>

int main(void)
{
    FILE *fp;
    int i = 0;
    char ch;
    char str[1024];
    char filename[64];
    printf("Input the file name to be opened : ");
    scanf("%s", filename);
    fp = fopen(filename, "r");
    while((ch = fgetc(fp)) != EOF){
        str[i++] = ch;
    }
    str[i] = '\0';
    printf("The content of the file %s are : \n", filename);
    printf("%s", str);
    
    return 0;
}